package main

import "fmt"

func testAdd(a int, b int) int {
	return a + b
}

func main() {
	//fmt.Printf("sum:%v\n",testAdd(1, 2))

	//a, b, c := calc.go(1, 2, 3)
	//fmt.Printf("a=%v,b=%v c=%v\n", a,b,c)

	//c, d := calc1(1, 2)

	//fmt.Printf("c=%v,d=%v \n", c, d)

	//var sum = calc2(1,2,3,4,5)
	//fmt.Printf("sum=%v\n",sum)

	sum := calc3(10, 1)
	fmt.Printf("sum:%v\n", sum)
}

func calc(a, b, c int) (int, int, int) {
	return a, b, c
}

func calc1(a, b int) (c int, d int) {
	c = a + b
	d = a - b
	return
}

//可变参数
func calc2(a ...int) int {
	num := 0
	for i := 0; i < len(a); i++ {
		num = a[i] + num
	}
	return num
}

//固定参数 与 可变参数 混合使用

func calc3(a int, b ...int) int {
	num := a
	for i := 0; i < len(b); i++ {
		num = b[i] + num
	}
	return num
}
